﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class UsercontentModel extends BaseModel
{

    var $table  = 'usertype';	

    var $_page_rows = 20;	
	
    /* 插入数据 */
    function insert_id( $table_id = 0,$userid = 0)
    {    

	     $this->IU_Sql_Exe(array ('table' => $this->_prefix . 'usertype_'.$table_id,'data' => array('user_id'=>$userid,'user_name'=>'0'), 'mode' => 'INSERT'));
		 
		 return $this->db->insert_id();	 
        
    }


    function select_id($table_id = 0,$userid = 0)
    {    
		 $info = $this->S_Sql_Exe(array('table' => $this->_prefix . 'usertype_'.$table_id,'fields' =>'id','conditions' =>"user_id = '{$userid}' and user_name = '0' "));
    
		 return $info;
        
    }


    function delet_id($table_id = 0,$userid = 0)
    {    
		return $this->D_Sql_Exe(array ('table' => $this->_prefix . 'usertype_'.$table_id,'conditions' =>"user_id = '{$userid}' and user_name = '0' "));
       
    }

	
    /* 插入数据 */
    function post($id,$data,$table_id=0)
    {    
	
		$time = time();  	      
	
		 $data['user_id'] =$data['user_id'];
		 $data['user_name'] =$data['user_name'];
	 
		 		 
        unset($data['yz'],$data['top'],$data['levels'],$data['special']); 
    
		$this->IU_Sql_Exe(array ('table' => $this->_prefix . 'usertype_'.$table_id,'data' => $data, 'mode' => 'INSERT'));

        
		
    }

    function show($order='',$v='',$table_id=0,$appname='')
    {  
		 
   	    $conditions = " user_name !='0' ";
		 
		  
	     $table = $this->_prefix.'usertype_'.$table_id.' ';
	  
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('table'=>"{$table}",'conditions' =>"{$conditions}",'url' => 'admin/?app=usercon&act=index&tid='.$table_id.'&v='.$v));		
		 
		 $info['data'] = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> ' * ','conditions' =>"{$conditions}",'order' =>"{$order}",'limit' =>$info['page']['sql_limit']));
    
		 return $info;
   
    }
	
	
    /* 删除数据 */
    function del($id ='',$table_id=0)
    {      
		$this->D_Sql_Exe(array ('table'=>"{$this->_prefix}usertype_{$table_id}",'conditions' =>"id = '{$id}' "));		
        
    }

    /* 修改数据 */
    function editaction($id ='',$data = '',$table_id=0)
    {    
		$time = time();  	      
			    
		$this->IU_Sql_Exe(array ('table' => $this->_prefix . 'usertype_'.$table_id,'data' => $data, 'mode' => 'UPDATE','conditions' =>"user_id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editpicurl($id ='',$data = '',$table_id=0)
    {   
		return $this->IU_Sql_Exe(array ('table'=>"{$this->_prefix}usertype_{$table_id}",'data' => $data,'mode' => 'UPDATE','conditions' =>" id = '{$id}' "));
        
    }




    /* 通过id取出一条数据 */
    function oneshow($id ='',$table_id=0)
    {    
	    

	     $table = $this->_prefix.'usertype_'.$table_id.'';
	  
		 $info = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> ' * ','conditions' =>"user_id='{$id}' and user_name!='0' ",'return' =>'one'));
    
		 return $info;
        
    }


}




?>